<?php
/* @var $this ShiftChangeController */
/* @var $model ShiftChange */
/* @var $form CActiveForm */
?>

<div class="form" style="width:420px;">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'shift-change-form',
	'enableAjaxValidation'=>false,
	'enableClientValidation'=>true,
	'clientOptions'=>array(
		'validateOnSubmit'=>true,)			
)); ?>

<center>
	<p class="note">Fields with <span class="required">*</span> are required.</p>
	<?php echo $form->errorSummary($model); ?>

<br>
	<div class="row">
		<?php
		echo CHtml::textField( 'date',$model->day_requested ,array('size'=>9,'readonly'=>true,'id'=>'ShiftChange_day_requested')) ;
		?>
	</div>
<p>
<table style="width:350px;">

	<tr>
		<td  colspan=2 >
			<div class="row compactRadioGroup">
			<?php echo CHtml::radioButtonList('choice',
											  'radioToShift',
											  array('radioToShift'=>'Direct Change',
													'radioToUser'=>'Change with User'),
											  array('separator' => '&nbsp&nbsp&nbsp|&nbsp&nbsp&nbsp&nbsp',
													'onclick'=>'radioToggle()'
													)
											  ); ?>
			</div>
		</td>
	</tr>
	
	<tr>
		<td >
		<div class="row">
				<?php echo $form->labelEx($model,'requested_shift'); ?>
					<?php echo $form->dropDownList($model,'requested_shift',
												   CHtml::listData(Shift::model()->findAll(array('condition'=>'team_id = '.$model->team_id.' and enabled = 1', 'order'=>'start_time ASC')),
																   'idshift', 
																   'name',
																   'start_time'),	
													array('empty'=>'','class'=>'dropshift','style'=>'visibility:visible;'));?>
				<?php echo $form->error($model,'requested_shift'); ?>
			</div>

			<div class="row" >
				<?php echo $form->labelEx($model,'requested_qshift'); ?>
					<?php echo $form->dropDownList($model,'requested_qshift',
												   CHtml::listData(Qshift::model()->findAll(array('condition'=>'team_id = '.$model->team_id.' and enabled = 1', 'order'=>'start_time ASC')),
																   'idqshift', 
																   'name'),	
													array('empty'=>'','class'=>'dropshift','style'=>'visibility:visible;'));?>		
				<?php echo $form->error($model,'requested_qshift'); ?>
			</div>
		</td>
		
		<td  >
			<div class="row">
				<?php echo $form->labelEx($model,'target_user'); ?>
					<?php echo $form->dropDownList($model,'target_user',
												   CHtml::listData(User::model()->findAll(array('condition'=>'team = '.$model->team_id, 'order'=>'username ASC')),
																   'iduser', 
																   'fullname'),	
													array('empty'=>'',
														  'class'=>'dropfullname',
														  'style'=>'visibility:hidden;',
														  'ajax' => array(
																		'type' => 'GET',
																		'url' => CController::createUrl('shiftChange/ajaxTargetShiftLoader'),
																		'data'=> array('target_user'=>'js: $(this).val()',
																					   'date'=>'js: $("#ShiftChange_day_requested").val()'),  
																		'update' => '#target_qshift',													
																		)												  
														  )
													);?>
				<?php echo $form->error($model,'target_user'); ?>
			</div>
			<div id='target_qshift' class='row'>

			</div>
		</td>
	</tr>
</table>

	<div class="row">
		<?php echo $form->labelEx($model,'comments'); ?>
		<?php echo $form->textArea($model,'comments',array('row'=>2,'maxlength'=>100)); ?>
		<?php echo $form->error($model,'comments'); ?>
	</div>
	
<br>
	<div class="buttons">
		<?php echo CHtml::submitButton('Create'); ?>
								
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->

